﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Reflection;
using System.Text;
using System.ComponentModel;
using System.Windows.Media;
using MCDomain.Common;
using CommonBase;

namespace MCDomain.Model
{
    public enum WellKnownApprovalstates
    {
        [Description("Подписано")]
        Signed = 2
    }

    partial class Approvalstate : IObjectId, INamed, IDataErrorInfo, IColor
    {
        public override string ToString()
        {
            return Name;
        }

        private readonly DataErrorHandlers<Approvalstate> _errorHandlers = new DataErrorHandlers<Approvalstate>
        {

        };


        public string Error
        {
            get { return this.Validate(); }
        }

        public string this[string columnName]
        {
            get { return _errorHandlers.HandleError(this, columnName); }
        }


        public Color WinColor
        {
            get
            {
                int nval;
                if (int.TryParse(Color.ToString(), out nval))
                {
                    var bytes = BitConverter.GetBytes(nval);
                    var color = System.Windows.Media.Color.FromRgb(bytes[2], bytes[1], bytes[0]);
                    return color;
                }
                return new Color() { R = 255, G = 255, B = 255 };
            }
        }

       
    }
}
